package org.shuma.goods.controller;

import org.shuma.goods.commons.Result;
import org.shuma.goods.service.ProductBasicInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/goods")
public class ProductBasicInfoController {
    @Autowired
    private ProductBasicInfoService productBasicInfoService;

    @GetMapping("/basic")
    public Result getProductBasicInfo(@RequestParam("productId") Integer productId) {
        return Result.success(productBasicInfoService.getProductBasicInfo(productId));
    }

    @GetMapping("/basic/page")
    public Result getProductBasicInfoPage(@RequestParam(defaultValue = "0") int pageNum,
                                          @RequestParam(defaultValue = "10") int pageSize,
                                            @RequestParam(value = "operator") Long userId) {
         ;
        return Result.success(productBasicInfoService.getProductBasicInfoList(userId,pageNum,pageSize));
    }

    @GetMapping("/status")
    public Result getProductStatus(@RequestParam("productCheckState") Integer productId,
                                   @RequestParam(defaultValue = "0") int pageNum,
                                   @RequestParam(defaultValue = "10") int pageSize) {
        return Result.success(productBasicInfoService.getProductStatus(productId,pageNum,pageSize));
    }
}

